package com.wifi.utils;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;

public class WifiUtils {
	private String TAG = "WIFIBULB";
	private int level;
	/**
	 * 设置listview的高度,在wifi扫描或者其他服务信号扫描时出现的listView
	 * */  
    public static class Utility {   
        public void setListViewHeightBasedOnChildren(ListView listView) {
        	
            ListAdapter listAdapter = listView.getAdapter();    
            if (listAdapter == null) {   
                return;   
            }   
            int totalHeight = 0;   
            for (int i = 0; i < listAdapter.getCount(); i++) {   
                View listItem = listAdapter.getView(i, null, listView);   
                listItem.measure(0, 0);   
                totalHeight += listItem.getMeasuredHeight();   
            }   
            ViewGroup.LayoutParams params = listView.getLayoutParams();   
            params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));   
            listView.setLayoutParams(params);   
        }   
    }

}
